package de.gameduell.framework.facebook.app.pages {
	import de.gameduell.framework.facebook.app.Controller;
	import de.gameduell.framework.facebook.app.GameData;
	import de.gameduell.framework.facebook.app.PageManager;
	import de.gameduell.framework.facebook.app.pyramide.Pyramid;
	import de.gameduell.framework.facebook.app.pyramide.PyramidView;

	import de.gameduell.framework.facebook.Page;
	import de.gameduell.framework.gui.button.Button;
	import de.gameduell.framework.gui.button.ButtonEvent;

	import flash.display.Sprite;
	import flash.events.Event;

	public class StartPage extends Page {
//		private var howToPlayButton:Button;
		private var pageManager:PageManager;
		private var pyramidView:PyramidView;

		public function StartPage(aPageManager:PageManager, anId:String) {
			super(aPageManager, anId);
			pageManager = aPageManager;
		}

		override protected function initPage():void {
			//			howToPlayButton = new Button(page.getChildByName("howToPlayButton") as Sprite, "howToPlayButton");
			//			howToPlayButton.addEventListener(ButtonEvent.CLICK, pageManager.prepareTutorialStart);
			//			howToPlayButton.active = true;
			//			howToPlayButton.sprite.alpha = 0;
			controller.collectUserData();
			pyramidView = new PyramidView(page);
//			Controller(controller).gameData.addEventListener(GameData.APP_INIT_DONE, handleHowToButton);
//			Controller(controller).gameData.pyramid.addEventListener(Pyramid.NEW_CONSTRUCTION, handleHowToButton);
		}

//		private function handleHowToButton(event:Event):void {
//			try {
//				if(int(Controller(controller).gameData.pyramid.currentBrick.id) > 18) {
//					howToPlayButton.sprite.visible = false;
//					Controller(controller).gameData.removeEventListener(GameData.APP_INIT_DONE, handleHowToButton);
//					Controller(controller).gameData.pyramid.removeEventListener(Pyramid.NEW_CONSTRUCTION, handleHowToButton);
//				} else {
//					howToPlayButton.sprite.alpha = 1;
//				}
//			}catch(e:Error) {
//				howToPlayButton.sprite.alpha = 1;
//			}
//		}
	}
}